package com.wei.czz.common.enums.store;

import com.wei.czz.common.dto.common.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-11-22 20:57:29
 * className: StoreStatusEnum
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum StoreStatusEnum {

    SAVE(0, "保存"),
    SUBMIT(10, "提交"),
    AUDIT_RETURN(20, "审核退回"),
    MODIFY(30, "修改"),
    MODIFY_RETURN(40, "审核退回修改"),
    FINISH(50, "审核通过")
    ;

    /**
     * 字典值
     */
    private final Integer value;

    /**
     * 字典值的描述信息
     */
    private final String name;

    public static List<NameValue<Integer>> getStatusEnumList() {
//        return Stream.of(
//                SAVE, SUBMIT, AUDIT_RETURN, MODIFY, MODIFY_RETURN, FINISH
//        )
        return Stream.of(values())
        .map(storeStatusEnum -> new NameValue<>(storeStatusEnum.getName(), storeStatusEnum.getValue()))
        .collect(Collectors.toList());
    }

    /**
     * 获取商店状态名称
     * @param status 商店状态
     * @return 商店状态名称
     */
    public static String getName(Integer status) {
        if (Objects.isNull(status)) {
            return "";
        }
        for (StoreStatusEnum storeStatusEnum : values()) {
            if (storeStatusEnum.value.equals(status)) {
                return storeStatusEnum.name;
            }
        }
        return "";
    }

    /**
     * 获取商店状态枚举映射
     * @return 映射结果
     */
    public static Map<Integer, String> getMap() {
        Map<Integer, String> map = new HashMap<>();
        for (StoreStatusEnum storeStatusEnum : values()) {
            map.put(storeStatusEnum.value, storeStatusEnum.name);
        }
        return map;
    }
}
